package com.itheima.controller;

import com.itheima.entity.LoginQueryParam;
import com.itheima.entity.LoginResponse;
import com.itheima.entity.Result;
import com.itheima.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;


    @PostMapping("/login")
    public Result login(@RequestBody LoginQueryParam param){
        LoginResponse lr=loginService.login(param);
        if(lr==null){
            return Result.error("用户名或密码错误");
        }
        return Result.success(lr);
    }
}
